import uvm_pkg::*;
`include "uvm_macros.svh"

class spt_base_sequence extends uvm_sequence #(spt_packet);
	`uvm_object_utils(spt_base_sequence)
	spt_packet req;
	int seq_item_max_num;
	
	extern function new(string name="spt_base_sequence");
	extern virtual task pre_body();
	extern virtual task post_body();
endclass:spt_base_sequence

function spt_base_sequence::new(string name="spt_base_sequence");
	super.new(name);
	this.seq_item_max_num=0;
endfunction:new

task spt_base_sequence::pre_body();
	if(starting_phase !=null)begin
	  starting_phase.raise_objection(this);
	end
endtask:pre_body

task spt_base_sequence::post_body();
	if(starting_phase !=null)begin
	  starting_phase.drop_objection(this);
	end
endtask:post_body

class spt_optional_pkt_sequence extends spt_base_sequence;
    `uvm_object_utils(spt_optional_pkt_sequence)
    int err_type;
	int payload_mode;
    int temp1;
    int temp2;
    
    function new(string name="spt_optional_pkt_sequence");
	super.new(name);
    endfunction:new
    
    task body();


       void'(uvm_config_db #(int)::get(null, get_full_name(), "seq_item_max_num", this.seq_item_max_num));
       `uvm_info(get_type_name(),$sformatf("body(): seq_item_max_num is %0d", this.seq_item_max_num),UVM_HIGH);
       void'(uvm_config_db #(int)::get(null, get_full_name(), "err_type", err_type));
        `uvm_info(get_type_name(),$sformatf("body(): err_type is %0d", err_type),UVM_HIGH);
       void'(uvm_config_db #(int)::get(null, get_full_name(), "payload_mode", payload_mode));
        `uvm_info(get_type_name(),$sformatf("body(): payload_mode is %0d", payload_mode),UVM_HIGH);
      
	   temp1=err_type; 
       temp2=payload_mode;

       repeat(this.seq_item_max_num)begin
    	  `uvm_do_with(req,{req.err_type==temp1;//00:normal;01:tail_err;10:head_err;11:head_err & tail_err;
    	  req.payload_mode==temp2;})//00:glitch;01:short;10:normal;11:long;
	   `uvm_info(get_type_name(),$sformatf("spt_seq gen packet: %s",req.sprint()),UVM_HIGH);
	   end
       #10us;
    endtask

endclass:spt_optional_pkt_sequence
